/*
 * Copyright 2012 Alibaba.com All right reserved. This software is the confidential and proprietary information of
 * Alibaba.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into with Alibaba.com.
 */
package com.goldplusgold.network.lib.exception;

/**
 * the exception caused when invoke a rpc, and server not return correct or connection lost.
 *
 * @author zhe.yangz 2012-1-17 下午06:57:53
 */
public class InvokeException extends HttpException {

    public static final int CODE_CONNECTION_ERROR = 1000;
    public static final int CODE_HTTP_PROTOCOL_ERROR = 1001;
    public static final int CODE_UNSUPPORT_ENCODING = 1002;
    public static final int CODE_PARSE_EXCEPTION = 1003;
    public static final int CODE_JSONPROCESS_EXCEPTION = 1004;
    public static final int CODE_IO_EXCEPTION = 1005;
    public static final int CODE_FULFILL_INVOKE_EXCEPTION = 1006;
    public static final int CODE_PARAM_IN_URL_NOT_FOUND = 1007;
    public static final int CODE_FILE_NOT_FOUND = 1008;
    public static final int CODE_TARGET_HOST_OR_URL_ERROR = 1009;
    public static final int CODE_FILE_SIZE_OVER_LIMIT = 1010;
    public static final int CODE_FILE_FORMAT_INVALID = 1011;
    public static final int CODE_FILE_UNABLE_TO_SAVE = 1012;
    public static final int CODE_USER_UN_SIGN_IN = 1088;
    public static final int CODE_UNKOWN_ERROR = 1099;
    private static final long serialVersionUID = -2431196726844826744L;
    /**
     * exception code
     */
    public int code;

    @SuppressWarnings("unused")
    private InvokeException() {
        super();
    }

    @SuppressWarnings("unused")
    private InvokeException(Throwable t) {
        super(t);
    }

    public InvokeException(int code, String msg) {
        super(msg);

        this.code = code;
    }

    public InvokeException(int code, String msg, Throwable t) {
        super(msg, t);

        this.code = code;
    }

    @Override
    public String toString() {
        return "[" + code + "] " + super.toString(); // defaults
    }
}
